package com.xiangge.domain;

import java.util.Objects;

public class Triangle {
    private double length;
    private double width;
    private double height;

    public double getArea() {
        double area = length * height / 2;
        return area;
    }
    public double getPerimeter(){
        double perimeter = length + width + height;
        return perimeter;
    }

    public Triangle() {
    }
    public Triangle(double length, double width, double height) {
        this.length = length;
        this.width = width;
        this.height = height;
    }

    public double getLength() {
        return length;
    }

    public void setLength(double length) {
        this.length = length;
    }

    public double getWidth() {
        return width;
    }

    public void setWidth(double width) {
        this.width = width;
    }

    public double getHeight() {
        return height;
    }

    public void setHeight(double height) {
        this.height = height;
    }

    @Override
    public String toString() {
        return "三角形的三条边分别是：" +
                "length=" + length +
                ", width=" + width +
                ", height=" + height;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Triangle triangle = (Triangle) o;
        return Double.compare(triangle.length, length) == 0 &&
                Double.compare(triangle.width, width) == 0 &&
                Double.compare(triangle.height, height) == 0;
    }

    @Override
    public int hashCode() {
        return Objects.hash(length, width, height);
    }
}
